from flask import Blueprint
from controllers.AdminController import AdminController
from controllers.SshController import SshController

admin = Blueprint('admin', __name__)

# 系统首页
admin.add_url_rule('/', view_func=AdminController().index, endpoint='index')

# 服务器管理
admin.add_url_rule('/resource_list', view_func=AdminController().resource_list, endpoint='resource_list')
admin.add_url_rule('/edit_resource', methods=['GET', 'POST'], view_func=AdminController().edit_resource, endpoint='edit_resource')
admin.add_url_rule('/delete_ecs', methods=['GET', 'POST'], view_func=AdminController().delete_ecs, endpoint='delete_ecs')

# 任务
admin.add_url_rule('/tasks_list', methods=['GET', 'POST'], view_func=AdminController().tasks_list, endpoint='tasks_list')
admin.add_url_rule('/test_task', methods=['GET', 'POST'], view_func=SshController().test_task, endpoint='test_task')
admin.add_url_rule('/edit_task', methods=['GET', 'POST'], view_func=AdminController().edit_task, endpoint='edit_task')
admin.add_url_rule('/delete_task', methods=['GET', 'POST'], view_func=AdminController().delete_task, endpoint='delete_task')
admin.add_url_rule('/tasks_log_list', methods=['GET', 'POST'], view_func=AdminController().tasks_log_list, endpoint='tasks_log_list')
admin.add_url_rule('/show_log_detail', methods=['GET', 'POST'], view_func=AdminController().show_log_detail, endpoint='show_log_detail')

# 任务分组
admin.add_url_rule('/tasks_group_list', methods=['GET', 'POST'], view_func=AdminController().tasks_group_list, endpoint='tasks_group_list')
admin.add_url_rule('/edit_tasks_group', methods=['GET', 'POST'], view_func=AdminController().edit_tasks_group, endpoint='edit_tasks_group')
admin.add_url_rule('/delete_group', methods=['GET', 'POST'], view_func=AdminController().delete_group, endpoint='delete_group')

# 执行服务器管理
admin.add_url_rule('/connect_test', methods=['GET', 'POST'], view_func=SshController().connect_test, endpoint='connect_test')
admin.add_url_rule('/start_task', methods=['GET', 'POST'], view_func=SshController().start_task, endpoint='start_task')
admin.add_url_rule('/stop_task', methods=['GET', 'POST'], view_func=SshController().stop_task, endpoint='stop_task')

# 用户
admin.add_url_rule('/users_list', methods=['GET', 'POST'], view_func=AdminController().users_list, endpoint='users_list')
admin.add_url_rule('/edit_user', methods=['GET', 'POST'], view_func=AdminController().edit_user, endpoint='edit_user')
